/*!
    \copyright  Copyright (c) 2023 Qualcomm Technologies International, Ltd.
                All Rights Reserved.
                Qualcomm Technologies International, Ltd. Confidential and Proprietary.
    \file
    \ingroup    le_scan_manager
    \brief      The events sent from the le_scan_manager using the Event Bus.
*/

#include "le_scan_manager_send_event.h"
#include "le_core_channel_event_spec.h"
#include "event_bus_publish.h"
#include <logging.h>

/*! \brief Send message through Event Bus

    \param event event bus event to publish.
    \param data data associated with the event
    \param data_size size of the data

*/
void static LeScanManager_PublishEvent(le_core_event_t event, void * data, uint16 data_size)
{
    EventBus_Publish(EVENT_BUS_CHANNEL_LE_CORE, event, data, data_size);
}

void LeScanManager_SendTransmitPowerReportingEvent(uint16_t connection_handle, uint8 reason,
                                                   uint8 phy, uint8 txPowerLevel, 
                                                   uint8 txPowerLevelFlag, uint8 delta)
{
    le_core_transmit_power_reporting_t event = {0};

    event.subevent_code = 0x21;
    event.status = hci_success;
    event.conn_handle = connection_handle;
    event.reason = reason;
    event.phy = phy;
    event.tx_power_level = txPowerLevel;
    event.tx_power_level_flag = txPowerLevelFlag;
    event.delta = delta;

    DEBUG_LOG("conManager_SendTransmitPowerReportingEvent");
    LeScanManager_PublishEvent(le_core_transmit_power_reporting, &event, sizeof(le_core_transmit_power_reporting_t));
}
